$(document).ready(function() {	

	$("#iframeLink").fancybox({
		'hideOnContentClick': true,
		'type'				: 'iframe',
		width				: '100%',
		height				: '100%'
	});



	// Candidate page upper slider
	$("#candidatePageUpperSliderCarousel li").hover(candidateSliderOver,candidateSliderOut);

	// Candidate Page Upper Sliders
	jQuery("#candidatePageUpperSliderCarousel").jcarousel({
        initCallback: candidateupperslider_mycarousel_initCallback,
        itemVisibleInCallback: {
		  onAfterAnimation: candidateupperslider_mycarousel_afterCallback
		},
		/*itemLastOutCallback: {
		  onAfterAnimation: candidateupperslider_mycarousel_lastCallback
		},*/
		auto : 2,
		scroll : 1,
		animation: "slow",
		wrap : "circular",
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
	
	// Home exams
	jQuery("#homeExamsCarousel").jcarousel({
        //initCallback: candidateupperslider_mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
		auto : 0,
		scroll : 1,
		animation: "slow",
		/*wrap : "circular",*/
		vertical: true
        //buttonNextHTML: '<a href="javascript:;" class="prevExams">&laquo;</a>',
       // buttonPrevHTML: '<a href="javascript:;" class="nextExams">&raquo;</a>'
    });
	
	// Home announcements
	jQuery("#announcementCarousel").jcarousel({
        //initCallback: candidateupperslider_mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
		auto : 2,
		scroll : 1,
		animation: "slow",
		wrap : "circular",
		vertical: true
        //buttonNextHTML: '<a href="javascript:;" class="prevExams">&laquo;</a>',
       // buttonPrevHTML: '<a href="javascript:;" class="nextExams">&raquo;</a>'
    });
	
	// Systems works
	jQuery("#systemWorksCarousel").jcarousel({
        //initCallback: candidateupperslider_mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
		auto : 0,
		scroll : 1,
		animation: "slow",
		vertical: true
        //buttonNextHTML: '<a href="javascript:;" class="prevExams">&laquo;</a>',
       // buttonPrevHTML: '<a href="javascript:;" class="nextExams">&raquo;</a>'
    });
	
	

	$('.nmCustomSelectBox').customStyle();

});

function closeFancy(){
	$.fancybox.close();
}
$(window).load(function() {
    $('#slider').nivoSlider({
        effect:'random', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:false, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
});
function candidateSliderOver()
{
	var carousel = jQuery('#candidatePageUpperSliderCarousel').data('jcarousel');
	carousel.stopAuto();
}
function candidateSliderOut()
{
	var carousel = jQuery('#candidatePageUpperSliderCarousel').data('jcarousel');
	carousel.startAuto();
}
function candidateupperslider_mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control-upper-slider a').bind('click', function() {		
		var scrollTarget = $(this).text();
        carousel.scroll(jQuery.jcarousel.intval(scrollTarget));
		$(this).parent().children().removeClass("selectedPaging");
		$(this).addClass("selectedPaging");
        return false;
    });
};

function candidateupperslider_mycarousel_afterCallback(carousel, item, idx, state)
{

	var currentDot = idx%carousel.options.size;
	if(currentDot == 0)
	{
		currentDot = carousel.options.size;
	}
	$(".jcarousel-control-upper-slider").children().removeClass("selectedPaging");
	$("#pagingDotUpper" + currentDot).addClass("selectedPaging");
}

function scrollHomeExamsNext(){
	var carousel = jQuery('#homeExamsCarousel').data('jcarousel');
	carousel.next();
}
function scrollHomeExamsPrev(){
	var carousel = jQuery('#homeExamsCarousel').data('jcarousel');
	carousel.prev();
}

function scrollAnnouncementNext(){
	var carousel = jQuery('#announcementCarousel').data('jcarousel');
	carousel.next();
}
function scrollAnnouncementPrev(){
	var carousel = jQuery('#announcementCarousel').data('jcarousel');
	carousel.prev();
}

function scrollSystemNext(){
	var carousel = jQuery('#systemWorksCarousel').data('jcarousel');
	carousel.next();
}
function scrollSystemPrev(){
	var carousel = jQuery('#systemWorksCarousel').data('jcarousel');
	carousel.prev();
}




